var Geo;
(function (Geo) {
    (function (ViewModel) {
        var User = (function () {
            function User() { }
            User.User = function User() {
                return $('#txtUser').val();
            };
            User.Save = function Save() {
                var newLog = Geo.Core.LogEntryRepository.Add(Geo.Core.Current, Geo.Enumerations.ActionTypes.DropOff, null, null, null, User.User());
                alert('Saved as ' + newLog.LogEntryLid);
            };
            return User;
        })();
        ViewModel.User = User;        
        Geo.Core.OnAfterInitialize.add(function () {
            if(Geo.Core.Current.PrivateKey === null) {
                Geo.Core.Navigation.GoToEntry();
                return;
            } else if(Geo.Core.Current.ActionType === null) {
                Geo.Core.Navigation.GoToAction();
                return;
            }
            $('#btnNext').bind('click', function () {
                if(Geo.Core.Current.LogEntryLid) {
                    Geo.Core.Current.UserInteractedWith = Geo.ViewModel.User.User();
                    Geo.Core.LogEntryRepository.Update(Geo.Core.Current);
                } else {
                    Geo.ViewModel.User.Save();
                }
                Geo.Core.Navigation.GoToView();
                return false;
            });
            $('#btnBack').bind('click', function () {
                if(Geo.Core.Current.LogEntryLid) {
                    Geo.Core.Navigation.GoToAction();
                } else {
                    Geo.Core.Navigation.GoToActionDetail(Geo.Core.Current.ActionType);
                }
                return false;
            });
        });
    })(Geo.ViewModel || (Geo.ViewModel = {}));
    var ViewModel = Geo.ViewModel;
})(Geo || (Geo = {}));
